// 导出组件
export { default as Example } from './comp'
 
// 导出描述 
export const description = `useContext 更方便的获取上下文`

// 导出组件代码文本
export const compstr = `
import React, { useContext } from 'react'

const ctx = React.createContext()
export default function comp() {
  return (
    <>
      <ctx.Provider value={{ n: 999 }}>
        <Child />
      </ctx.Provider>
    </>
  )
}

function Child() {
  const data = useContext(ctx)
  return (
    <>
      <div>上下文数据：{data.n}</div>
      {/* 之前的方式获取上下文 */}
      <ctx.Consumer>
        {(data) => {
          return <div>上下文数据：{data.n}</div>
        }}
      </ctx.Consumer>
    </>
  )
}
`